#!/bin/bash
export TZ=UTC
TTY=$1
STTY=$(echo $1|sed -e 's/tty//g')
	mqtt_host=mqtt
	uid=$(echo $(/sbin/udevadm info --name=/dev/${TTY}|sed -n '/MAJOR/{s/[A-Z: =]*//;p}')*256+$(/sbin/udevadm info --name=/dev/${TTY}|sed -n '/MINOR/{s/[A-Z: =]*//;p}')|bc)
	topicrmc="gps/$(/bin/hostname)/${uid}"
	/bin/cat /dev/${TTY}|/usr/bin/unbuffer -p /bin/grep -e GBS -e GST -e GSV -e GRS -e GSA -e GGA -e RMC |/usr/bin/unbuffer -p /usr/bin/cut -d* -f1 |/usr/bin/unbuffer -p /usr/bin/gawk -f /home/pi/ragps/gps_pre.awk |while read rmc; do 
		/usr/bin/mosquitto_pub -h ${mqtt_host} -t ${topicrmc} -m "$(echo ${rmc}|sed -e 's/[,]*,/,/g'|sed -e 's/,}/}/g;s/:,/:null,/g;s/:}/:null}/g'|jq -c 'del(.[] | nulls)')"
	done
# gbs
